package reflect;

import javax.xml.transform.Source;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.sql.SQLOutput;

public class ReflectDemo6 {
    public static void main(String[] args) throws Exception{
        Class cls = Class.forName("reflect.Person");
        Method method = cls.getMethod("say",String.class,int.class);
        String name = method.getName();
        System.out.println(name);
        Class returnType = method.getReturnType();
        System.out.println(returnType);
        int count = method.getParameterCount();
        System.out.println(count);

        Class[] paramTypes = method.getParameterTypes();
        for(Class paramType:paramTypes){
            System.out.println(paramType);
        }

        int modifiers = method.getModifiers();
        switch(modifiers){
            case Modifier.PUBLIC:
                System.out.println("这是一个public方法");
                break;
            case Modifier.PROTECTED:
                System.out.println("这是一个protected方法");
                break;
            case Modifier.PRIVATE:
                System.out.println("这是一个private方法");
                break;
            default:
                System.out.println("这是一个default方法");

        }
    }
}
